﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using ClassLibrary.DAO;
using ClassLibrary.Entity;

public partial class Admin_MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //try
            //{
                if (Session[Global.SESSION_LOGGED_ADMIN] != null)
                    lblSession.Text = ((TblCustomers)Session[Global.SESSION_LOGGED_ADMIN]).FName + " " + ((TblCustomers)Session[Global.SESSION_LOGGED_ADMIN]).LName;
                else
                    Response.Redirect("~/Admin/Login.aspx");

                LoadCSS();
            //}
            //catch (Exception ex)
            //{
            //    Session[Global.SESSION_ERROR] = ex;
            //    Response.Redirect(Global.ERROR_PAGE_ADMIN);
            //}
        }
    }

    private void LoadCSS()
    {
        string idCSS = Global.GetPageName(Request.ServerVariables["SCRIPT_NAME"].ToString());
        if ((idCSS == "ListEmail_NotActive.aspx"))
        {
            aListEmail_NotActive.Attributes.Add("class", "menu_select");
        }

        if ((idCSS == "ListEmailActive.aspx"))
        {
            aListEmailActive.Attributes.Add("class", "menu_select");
        }
        if ((idCSS == "ListOrder.aspx"))
        {
            aListOrder.Attributes.Add("class", "menu_select");
        }

        if ((idCSS == "ListCustomers.aspx"))
        {
            aListCustomers.Attributes.Add("class", "menu_select");
        }

    }

    protected void btnLogout_Click(object sender, EventArgs e)
    {
        try
        {
            Session[Global.SESSION_LOGGED_ADMIN] = null;
            Session.RemoveAll();
            Session.Clear();
            Response.Redirect("~/Admin/Login.aspx", false);
        }
        catch (Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE_ADMIN);
        }
    }
}
